
const searchFormList = [
  { label: '', width: '130px', value: 'btnOperation', type: 'slot' },
	{ label: '关键词', value: 'query', type: 'input', width: '200px' },
  { label: '部署位置', value: 'ostype', type: 'select', width: '200px', option: 'sysAdsOstype', filterable: true,  clearable: true},
	{ label: '', width: '200px', value: 'btnSearch', type: 'slot' }
];

const tables = [ // 表格数据
  { label: '记录ID', value: 'id', sort:'custom'},
  { label: '名称', value: 'name'},
  { label: '广告图', value: 'ads', type: 'slot'},
  { label: '跳转链接', value: 'link', type: 'slot'},
  { label: '部署位置', value: 'ostype', type: 'slot'},
  { label: '是否内部打开', value: 'isinner', type: 'slot'},
  { label: '是否需要登录', value: 'issignin', type: 'slot'},
  { label: '排序', value: 'rank', width:70},
  { label: '点击量', value: 'clicks', width:70},
  { label: '浏览量', value: 'viewer', width:70},
  { label: '开始时间', value: 'start'},
  { label: '过期时间', value: 'expire'},
  { label: '更新时间', value: 'stime'}
];

const fieldList = [ // 新增弹出数据
  { label: '名称', value: 'name', type: 'input', width: '300px'},
  { label: '跳转链接', value: 'link', type: 'input', width: '420px'},
  { label: '广告图', value: 'ads', type:'file', width: '300px', accept:'image/jpeg,image/gif,image/png', multiple:false, data:{skey:'file',appdir:'ads'}},
  { label: '开屏长图', value: 'lads', type:'file', width: '300px', accept:'image/jpeg,image/gif,image/png', multiple:false, data:{skey:'file',appdir:'ads'}},
  { label: '排序', value: 'rank', type:'input', width: '300px', className:''},
  { label: '部署位置', value: 'ostype', type:'select', width: '300px', option: 'sysAdsOstype', filterable: true, className:''},
  { label: '是否内部打开', value: 'isinner', type:'select', width: '300px', option: 'yesOrNo', filterable: true, className:''},
  { label: '是否需要登录', value: 'issignin', type:'select', width: '300px', option: 'yesOrNo', filterable: true, className:''},
  { label: '开始时间', value: 'start', type:'date', width: '300px', dateType:'datetime', format:"yyyy-MM-dd HH:mm:ss", className:''},
  { label: '过期时间', value: 'expire', type:'date', width: '300px', dateType:'datetime', format:"yyyy-MM-dd HH:mm:ss", className:''},
];

const rules = {
	name: [{ required: true, message: '请输入名称', trigger: 'change' }],
  ads: [{ required: true, message: '请上传广告图', trigger: 'change' }],
	rank: [{ required: true, message: '请输入排序', trigger: 'change' }],
  start: [{ required: true, message: '请设置生效时间', trigger: 'change' }],
  expire: [{ required: true, message: '请设置结束时间', trigger: 'change' }],
  ostype: [{ required: true, message: '请选择部署位置', trigger: 'change' }],
  isinner: [{ required: true, message: '请选择是否内部打开', trigger: 'change' }],
  issignin: [{ required: true, message: '请选择是否需要登录', trigger: 'change' }]
};

const fieldData = (data)=>{
  var dataset = {};
  for (var idx = 0; idx < fieldList.length; idx++) {
    var ckey  = fieldList[idx].value;
    dataset[ckey] = (data)? data[ckey]:'';
  }
  dataset.id = (data && data.id)? data.id:0;
  return dataset;
}

export default {
  searchFormList,tables,fieldList,fieldData,rules
};